#include <stdio.h>

// 移除指定元素
int removeElement(int *nums, int numsSize, int val)
{
    int right = 0;
    int left = 0;
    while (left < numsSize)
    {
        if (nums[left] != val)
        {
            nums[right] = nums[left];
            right++;
        }
        left++;
    }
    for (int i = 0; i < right; i++)
    {
        printf("%d ", nums[i]);
    }
    printf("\n");
    return right;
}

int main()
{
    int nums[] = {0,1,2,2,3,0,4,2};
    int val = 0;
    int len = sizeof(nums) / sizeof(nums[0]);
    int ret = removeElement(nums, len, val);
    printf("%d\n", ret);
}
